package 笔试强训day18;
import java.util.*;

import java.io.*;

public class Test2 {
    //第二题: chika和蜜柑
    public static class Migang{
        int sweet;
        int suan;
        public Migang(int sweet,int suan) {
            this.sweet = sweet;
            this.suan  = suan;
        }
        //写一个无参的
        public Migang(){}
    }

    public static void main(String[] args) throws IOException{
        //要用IO流输入
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //输入要带空格
        String[] tmp = reader.readLine().split(" ");
        int n = Integer.parseInt(tmp[0]);
        int k = Integer.parseInt(tmp[1]);
        String[] ai = reader.readLine().split(" ");
        String[] bi = reader.readLine().split(" ");

        //要用一个优先级队列   记录一下 甜度和酸度  甜度要降序排序  甜度相同的时候 酸度升序排序
        PriorityQueue<Migang> queue = new PriorityQueue<>((Migang m1, Migang m2) -> {
            //lambda表达式的形式表示内部类  写排序原则
            if(m1.sweet == m2.sweet) {
                return m1.suan - m2.suan;
            }else{
                return m2.sweet - m1.sweet;
            }
        });

        for(int i = 0; i< n;i++) {
            //转为整形
            Migang migang = new Migang();
            migang.suan = Integer.parseInt(ai[i]);
            migang.sweet = Integer.parseInt(bi[i]);
            queue.add(migang);
        }

        long tianSum = 0;
        long suanSum = 0;
        for(int i = 0; i < k; i++) {
            Migang m = queue.poll();
            suanSum += m.suan;
            tianSum += m.sweet;
        }

        System.out.println(suanSum + " " + tianSum);
    }
}
